| Class | WebmasterTools::Sitemaps::Node |
| In: |
lib/webmaster_tools/sitemaps.rb
|
| Parent: | Object |
Node is the generic class that represents a sitemap node. You can create non-ActiveRecord models and as long as they define a to_sitemap_node you can use this node to add sitemappable ability to your site.
This is particularly useful if you have a flat file that lists urls
| changefreq | [RW] | |
| host | [RW] | |
| lastmod | [RW] | |
| path | [RW] | |
| priority | [RW] | |
| protocol | [RW] |
# File lib/webmaster_tools/sitemaps.rb, line 44
44: def initialize(options)
45: [:protocol, :host, :path, :lastmod, :priority, :changefreq].each do |field|
46: self.send("#{field}=",options[field])
47: end
48: end
Outputs the contents of the current node to a valid sitemap element
# File lib/webmaster_tools/sitemaps.rb, line 51
51: def to_xml(options = {})
52: options[:indent] ||= 2
53: xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
54: xml.instruct! unless options[:skip_instruct]
55: xml.url do
56: xml.tag!(:loc, "#{protocol || options[:protocol]}#{host || options[:host]}#{path}")
57: xml.tag!(:lastmod, lastmod.xmlschema) if lastmod.respond_to?(:xmlschema)
58: xml.tag!(:priority, priority)
59: xml.tag!(:changefreq, changefreq)
60: end
61: end